package com.fr.report.semantic;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class IndexGroup
  implements XMLReadable, Serializable, Cloneable
{
  private int index;
  private List indexSummaryList = new ArrayList();

  public IndexGroup()
  {
  }

  public IndexGroup(int paramInt)
  {
    this.index = paramInt;
  }

  public int getIndex()
  {
    return this.index;
  }

  public void setIndex(int paramInt)
  {
    this.index = paramInt;
  }

  public void addIndexSummary(IndexSummary paramIndexSummary)
  {
    this.indexSummaryList.add(paramIndexSummary);
  }

  public int getIndexSummaryCount()
  {
    return this.indexSummaryList.size();
  }

  public IndexSummary getIndexSummary(int paramInt)
  {
    return ((IndexSummary)this.indexSummaryList.get(paramInt));
  }

  public void clearIndexSummarys()
  {
    this.indexSummaryList.clear();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
      this.indexSummaryList.clear();
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if ("IndexGroupAttr".equals(str2))
      {
        String str1;
        if ((str1 = paramXMLableReader.getAttr("index")) != null)
          setIndex(Integer.parseInt(str1));
      }
      else if ("IndexSummary".equals(str2))
      {
        IndexSummary localIndexSummary = new IndexSummary();
        paramXMLableReader.readXMLObject(localIndexSummary);
        addIndexSummary(localIndexSummary);
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    int i;
    paramXMLPrintWriter.startTAG("IndexGroupAttr").attr("index", getIndex()).end();
    if (getIndexSummaryCount() > 0)
      for (i = 0; i < getIndexSummaryCount(); ++i)
      {
        IndexSummary localIndexSummary = getIndexSummary(i);
        paramXMLPrintWriter.startTAG("IndexSummary");
        localIndexSummary.writeXML(paramXMLPrintWriter);
        paramXMLPrintWriter.end();
      }
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    IndexGroup localIndexGroup = (IndexGroup)super.clone();
    localIndexGroup.indexSummaryList = new ArrayList();
    int i = 0;
    int j = getIndexSummaryCount();
    while (i < j)
    {
      localIndexGroup.indexSummaryList.add(getIndexSummary(i).clone());
      ++i;
    }
    return localIndexGroup;
  }
}